{% extends "student/base.html" %}
{% block title %}个人信息{% endblock %}
{% block content %}
    <style>
        .bg-gray-50 {
    cursor: not-allowed;
}</style>
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
    <!-- 个人信息卡片 -->
    <div class="bg-white rounded-2xl shadow-lg overflow-hidden mb-8 transition-all duration-300 hover:shadow-xl">
        <div class="flex flex-col md:flex-row">
            <!-- 头像区域 -->
            <div class="bg-gradient-to-br from-blue-50 to-blue-100 p-8 md:p-10 flex-col items-center justify-center">
                <div class="w-40 h-40 rounded-full overflow-hidden border-4 border-white shadow-lg">
                    <img src="https://picsum.photos/100/100"
                         alt="学生头像"
                         class="w-full h-full object-cover" type="image/webp">
                </div>
                <p class="mt-4 text-sm text-gray-500 text-center">头像由管理员统一设置</p>
            </div>

            <!-- 基本信息区域 -->
            <div class="p-8 md:p-10 flex-1">
                <div class="flex flex-col md:flex-row md:items-center justify-between mb-8">

                    <div>
                        <h2 class="text-2xl font-bold text-gray-800 mb-2">
                            {{ student.username }}

                        </h2>
                        <p class="text-lg text-gray-600">
                            <span class="mr-6">
                                <i class="fa fa-graduation-cap text-gray-500 mr-1"></i>
                               {{ student.student_no }}
                            </span>
                            <span>
                                <i class="fa fa-users text-gray-500 mr-1"></i>
                               {{ student.class_.class_name if student.class_ else '未分配班级' }}
                            </span>
                        </p>
                    </div>



                    <!-- 保存按钮 -->
                    <div class="mt-6 md:mt-0 flex gap-4">
                        <button id="saveBtn" class="btn bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-md transition-all">
                            <i class="fa fa-save mr-2"></i> 保存更改
                        </button>
                    </div>
                </div>

                <!-- 表单区域 -->
                <form id="profileForm" method="POST" action="#" novalidate>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-6">

                        <!-- 联系电话 -->
                        <div>
                            <label for="telephone" class="block text-sm text-gray-500 mb-1">联系电话</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-phone"></i>
                                </span>
                                <input type="text" id="telephone" name="telephone"
                                       value="{{ student.telephone or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>

                        <!-- 年龄 -->
                        <div>
                            <label for="age" class="block text-sm text-gray-500 mb-1">年龄</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-birthday-cake"></i>
                                </span>
                                <input type="number" id="age" name="age"
                                       value="{{ student.age or '' }}"
                                       min="10" max="100"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>

                        <!-- 性别 -->
                        <div>
                            <label for="gender" class="block text-sm text-gray-500 mb-1">性别</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-user"></i>
                                </span>
                                <select id="gender" name="gender"
                                        class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                                    <option value="">请选择</option>
                                    <option value="男" {{ 'selected' if student.gender == '男' }}>男</option>
                                    <option value="女" {{ 'selected' if student.gender == '女' }}>女</option>
                                    <option value="其他" {{ 'selected' if student.gender == '其他' }}>其他</option>
                                </select>
                            </div>
                        </div>

                        <!-- 所属班级 -->


  <div>
            <label class="block text-sm text-gray-500 mb-1">所属班级</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-users"></i>
                </span>
                <div class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-gray-50 text-gray-700">
                    {{ student.class_.class_name if student.class_ else '未分配班级' }}
                </div>
                <input type="hidden" id="class_id" name="class_id" value="{{ student.class_id or '' }}">
            </div>
        </div>




     <!-- 新增专业字段（文本框示例） -->
        <div>
            <label for="major" class="block text-sm text-gray-500 mb-1">专业</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-book"></i>
                </span>
                <input type="text" id="major" name="major"
                       value="{{ student.major or '' }}"
                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
            </div>
        </div>
                        <!-- 学生状态 -->
                         <!-- 学生状态（只读显示） -->
        <div>
            <label class="block text-sm text-gray-500 mb-1">学生状态</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-info-circle"></i>
                </span>
                <div class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-gray-50 text-gray-700">
                    {{ student.status or '未设置' }}
                </div>
                <input type="hidden" id="status" name="status" value="{{ student.status or '' }}">
            </div>
        </div>


                        <!-- 地址（原宿舍地址） -->
                        <div>
                            <label for="address" class="block text-sm text-gray-500 mb-1">地址</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-home"></i>
                                </span>
                                <input type="text" id="address" name="address"
                                       value="{{ student.address or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>
                    </div>

                    <!-- 密码修改区域 -->
                    <div id="passwordSection" class="mt-8">
                        <h3 class="text-lg font-medium text-gray-800 mb-4">修改密码</h3>

                        <div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-6">
                            <!-- 当前密码 -->
                            <div class="md:col-span-2">
                                <label for="current_password" class="block text-sm text-gray-500 mb-1">当前密码</label>
                                <div class="relative">
                                    <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                        <i class="fa fa-lock"></i>
                                    </span>
                                    <input type="password" id="current_password" name="current_password"  value="{{ student.password or '' }}"
                                           class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                                           placeholder="请输入当前密码">
                                    <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleCurrentPassword">
                                        <i class="fa fa-eye-slash text-gray-500" id="currentPasswordIcon"></i>
                                    </button>
                                </div>
                            </div>

                            <!-- 新密码 -->
                            <div>
                                <label for="new_password" class="block text-sm text-gray-500 mb-1">新密码</label>
                                <div class="relative">
                                    <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                        <i class="fa fa-key"></i>
                                    </span>
                                    <input type="password" id="new_password" name="new_password"
                                           class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                                    <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleNewPassword">
                                        <i class="fa fa-eye-slash text-gray-500" id="newPasswordIcon"></i>
                                    </button>
                                </div>
                            </div>

                            <!-- 确认新密码 -->
                            <div>
                                <label for="confirm_password" class="block text-sm text-gray-500 mb-1">确认新密码</label>
                                <div class="relative">
                                    <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                        <i class="fa fa-check-circle"></i>
                                    </span>
                                    <input type="password" id="confirm_password" name="confirm_password"
                                           class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                                    <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleConfirmPassword">
                                        <i class="fa fa-eye-slash text-gray-500" id="confirmPasswordIcon"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

    <script src="{{ url_for('static', filename='js/student_js/message.js') }}"></script>
{% endblock %}